package com.chen.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.chen.common.PageResult;

import com.chen.pojo.EmpDO;
import com.chen.utils.BaseMapperX;

import com.chen.utils.LambdaQueryWrapperX;
import com.chen.vo.emp.EmpPageReqVO;
import org.apache.ibatis.annotations.Mapper;

/**
 * <p>
 * 员工表 Mapper 接口
 * </p>
 *
 * @author chen
 * @since 2024-04-10
 */
@Mapper
public interface EmpMapper extends BaseMapperX<EmpDO> {
    /**
     * 分页查询
     * @param reqVO
     * @return
     */
    default public PageResult<EmpDO> selectPage(EmpPageReqVO reqVO){
      return  selectPage(reqVO,new LambdaQueryWrapperX<EmpDO>()
                .likeIfPresent(EmpDO::getName,reqVO.getName())
                .eqIfPresent(EmpDO::getGender,reqVO.getGender())
                .ltIfPresent(EmpDO::getCreateTime,reqVO.getEnd())
                .geIfPresent(EmpDO::getCreateTime,reqVO.getBegin()));

    }


    default EmpDO selectEmpByUsername(String username){
        return selectOne(new LambdaQueryWrapper<EmpDO>()
                .eq(EmpDO::getUsername,username));
   }
}
